<?php
class Default_Model_DbTable_Partner extends Zend_Db_Table_Abstract
{
	protected $_name="hae_partner";
	protected $_sequence=true;
	protected $_primary="id";
	
	public function getAllPartner() 
	{	
	    //Locale
	    $locale = new HAE_Element_Locale();
	    $lang = $locale->getLocale();
	    
	    //Query
	    $select = $this->select();
		$select->from($this->_name,array('id','name', 'alias', 'desc_'.$lang.' AS desc', 'image', 'website', 'status', 'priority'));
		$select->where('status = 1');			
		
		//Result		
		$adaptor = new Zend_Paginator_Adapter_DbTableSelect($select);
		return $adaptor;
	}
	public function getListPartner() 
	{	
	    //Locale
	    $locale = new HAE_Element_Locale();
	    $lang = $locale->getLocale();
	    
	    //Config
	    $itemsPerPage = 1;
	    
	    //Query
	    $select = $this->select();
		$select->from($this->_name,array('id','name', 'alias', 'desc_'.$lang.' AS desc', 'image', 'website', 'status', 'priority'));
		$select->where('status = 1');			
		
		
		//Result		
// 		$adaptor = new Zend_Paginator_Adapter_DbTableSelect($select);
		$adaptor = new Zend_Paginator_Adapter_DbSelect($select);
		$rows = new Zend_Paginator($adaptor);
		$rows->setCurrentPageNumber($page);
		$rows->setItemCountPerPage($itemsPerPage);		
		return $rows;
	}
	
	public function getDetailPartner() 
	{	
	    //Locale
	    $locale = new HAE_Element_Locale();
	    $lang = $locale->getLocale();
	    
	    //Query
	    $select = $this->select();
		$select->from($this->_name,array('id','name', 'alias', 'desc_'.$lang.' AS desc', 'image', 'website', 'status', 'priority'));
		$select->where('status = 1');			
		
		//Result		
		$adaptor = new Zend_Paginator_Adapter_DbTableSelect($select);
		return $adaptor;
	}
	
}
?>